// https : // iai.sh.cn/problem/30
#include <bits/stdc++.h>
using namespace std;
int a[1000005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  sort(a + 1, a + n + 1);
  int j = 1;
  int i = 1;
  while (i <= n && j <= n) {
    while (j <= n && a[j] - i + 1 < 0) {
      j++;
    }
    if (j > n)
      break;
    ans++;
    i++;
  }
  cout << ans;
  return 0;
}